﻿package com.shangda.Server;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class MyClient extends Thread{
	 	Socket sk = null;  
	    BufferedReader reader = null;  
	    OutputStream wtr = null;  
	   // OutputStream out = null;
	   // BufferedReader keyin = null;  
	  
	    public MyClient()  
	    {  
	       // keyin = new BufferedReader(new InputStreamReader(System.in));  
	        try  
	        {  
	            sk = new Socket("`127.0.0.1", 8991);  
	        }  
	        catch (Exception e)  
	        {  
	            e.printStackTrace();  
	        }  
	  
	    }  
	  
	    public void run()  
	    {  
	        try  
	        {   
	            wtr = sk.getOutputStream();  
	           // String get = keyin.readLine();  
	  
	            while (true)  
	            {  
	            	byte [] buf = { 0x23,0x23,0x32,0x30,0x31,0x36,0x30,0x33,
							 0x31,0x36,0x31,0x32,0x33,0x34,0x31,0x34,
							 0x30,0x30,0x35,0x31,0x00,0x0c,0x09,0x02,
							 0x00,0x00,0x1f,0x02,0x00,0x00,0x02,0x01,
							 0x00,0x00,0x19,0x01,0x00,0x00,0x2a,0x00,
							 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
							 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x38,
							 0x3f,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
							 0x00,0x00,0x03,0x0c,0x55,0x15,0x18,0x62,
							 0x31,0x1a,0x0d,0x0a};
	            	//char [] buf = {0x23};
	            	
	            	wtr.write(buf);
	            	wtr.flush();
	            	sleep(3000);
	                /*if (get != null & get.length() > 0)  
	                {  
	                    wtr.println(get);  
	                    wtr.flush();  
//	                  wtr.close();  
//	                  System.out.println(get + "发送完毕");  
	                }  */
	                if (reader != null)  
	                {  
	                    String line = reader.readLine();  
	                    System.out.println("从服务器来的信息：" + line);  
	                      
	                }  
	                  
	            }  
	        }  
	        catch (Exception e)  
	        {  
	            e.printStackTrace();  
	        }  
	    }  
	    
	    public static void main(String[] args) throws Exception {
	    	/*for (int i=0;i<10;i++){
	    		new MyClient().start();
	    		
	    	}*/
	    	for (int i=0;i<1000;i++){
	    		new Socket("127.0.0.1", 8991);  
	    	}
	    	Thread.sleep(10000);
	    		
		}

}
